package com.binance.notification.web.service.abnormaltrade.enums;
/**
 * 针对k线的时间跨度参数用枚举封装，增加可读性
 * */
public enum IntervalEnum {
  ONE_DAY("1d", 60 * 60 * 24L),
  THREE_DAY("3d", 60 * 60 * 24 * 3L),
  ONE_WEEK("1w", 7 * 60 * 60 * 24L),
  ONE_MONTH("1M", 30 * 60 * 60 * 24L),
  ONE_HOUR("1h", 60 * 60 * 1L),
  TWO_HOUR("2h", 60 * 60 * 2L),
  FOUR_HOUR("4h", 60 * 60 * 4L),
  SIX_HOUR("6h", 60 * 60 * 6L),
  EIGHT_HOUR("8h", 60 * 60 * 8L),
  TWELVE_HOUR("12h", 60 * 60 * 12L),
  ONE_MINUTES("1m", 60 * 1L),
  THREE_MINUTES("3m", 60 * 3L),
  FIVE_MINUTES("5m", 60 * 5L),
  FIFTEEN_MINUTES("15m", 60 * 15L),
  THIRTY_MINUTES("30m", 60 * 30L);

  IntervalEnum(String name, Long second) {
    this.name = name;
    this.second = second;
  }

  private String name;
  private Long second;

  public String getName() {
    return name;
  }

  public Long getSecond() {
    return second;
  }

  public static IntervalEnum forName(String name) {
    for (IntervalEnum intervalEnum : IntervalEnum.values()) {
      if (intervalEnum.getName().equals(name)) {
        return intervalEnum;
      }
    }
    return null;
  }
}
